/**
 * An irrational decimal fraction is created 
 * by concatenating the positive integers: 
 * 0.123456789101112131415161718192021... 
 * It can be seen that the 12th digit of the fractional part is 1.
 * If dn represents the nth digit of the fractional part, 
 * find the value of the following expression.
 * d1 × d10 × d100 × d1000 × d10000 × d100000 × d1000000
 */

/**
 * @author TrinhNX
 * @start_date	: 2015/05/07
 * @end_date 	:
 */
public class Euler040 {
	public static void main(String[] args) {
		final int MAX = 1000000;
		final long start = System.currentTimeMillis();
		StringBuilder sb = new StringBuilder(1000);
		for(int i = 1; sb.length() < MAX; i++ ) {
			sb.append(i);
		}
		System.out.println((sb.charAt(0) - '0') 
				* (sb.charAt(9) - '0') 
				* (sb.charAt(99) - '0') 
				* (sb.charAt(999) - '0')
				* (sb.charAt(9999) - '0') 
				* (sb.charAt(99999) - '0') 
				* (sb.charAt(999999) - '0'));
		System.out.println("End after: " + (System.currentTimeMillis() - start));
//		long startTime = System.currentTimeMillis();
//		StringBuilder sb = new StringBuilder();
//		String s = "";
//		for (int i = 1; sb.length() < 1000000; i++) {
//			sb.append(i);
//		}
//		s = sb.toString();
//		int ans = Integer.parseInt(new Character(s.charAt(1 - 1)).toString());
//		ans *= Integer.parseInt(new Character(s.charAt(10 - 1)).toString());
//		ans *= Integer.parseInt(new Character(s.charAt(100 - 1)).toString());
//		ans *= Integer.parseInt(new Character(s.charAt(1000 - 1)).toString());
//		ans *= Integer.parseInt(new Character(s.charAt(10000 - 1)).toString());
//		ans *= Integer.parseInt(new Character(s.charAt(100000 - 1)).toString());
//		ans *= Integer.parseInt(new Character(s.charAt(1000000 - 1)).toString());
//		System.out.println(ans);
//		System.out.println((System.currentTimeMillis() - startTime) + "ms");
	}
}
